package edu.jit.flowers.dao;

import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import edu.jit.flowers.bean.Orderdetails;
import edu.jit.flowers.utils.JDBCUtil;

public class OrderdetailsDAO {
	//查看订单详情 error
	public Orderdetails selectAllOrderdetails(){
		Orderdetails orderdetails= null;
		String sql="select od_id as odid,od_f_id as odfid,od_o_id as odoid,"
				+ "od_price as odprice,od_total as odtotal,od_amount as odamount"
				+ "from flowers,orders,orderdetails"
				+ "where flowers.f_id=orderdetails.od_f_id and"
				+ "orders.o_id=orderdetails.od_o-id";
		QueryRunner runner=new QueryRunner(JDBCUtil.getDataSource());
		try {
			orderdetails = runner.query(sql, new BeanHandler<>(Orderdetails.class));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return orderdetails;
	}
}
